package com.jianhua.backend.controller;

import com.jianhua.backend.common.R;
import com.jianhua.backend.domain.dto.DishesDto;
import com.jianhua.backend.domain.dto.ExceptionRecordsDto;
import com.jianhua.backend.domain.entity.ExceptionRecords;
import com.jianhua.backend.domain.vo.PageVo;
import com.jianhua.backend.service.ExceptionRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 记录订单处理过程中的异常情况 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-07-02
 */
@RestController
@RequestMapping("/exception-records")
public class ExceptionRecordsController {

    @Autowired
    private ExceptionRecordsService exceptionRecordsService;

    /**
     * 获取异常记录列表
     * 该接口用于接收前端传来的异常记录查询条件，并返回符合条件的异常记录分页列表。
     *
     * @param exceptionRecordsDto 异常记录查询条件的DTO对象
     * @return 返回包含异常记录分页列表的响应对象
     */
    @PostMapping("/list")
    public R listExceptionRecords(@RequestBody ExceptionRecordsDto exceptionRecordsDto){
        PageVo<ExceptionRecords> exceptionRecordsPageVo = exceptionRecordsService.listExceptionRecords(exceptionRecordsDto);
        return R.success(exceptionRecordsPageVo);
    }

    @PostMapping("/update")
    public R updateExceptionRecords(@RequestBody ExceptionRecords exceptionRecords){
        exceptionRecordsService.updateExceptionRecords(exceptionRecords);
        return R.success(null);
    }

}
